package com.wj.rpsm.admin.controller;

import com.wj.rpsm.admin.pojo.PageResult;
import com.wj.rpsm.admin.pojo.ResponsePojo;
import com.wj.rpsm.admin.pojo.Room;
import com.wj.rpsm.admin.service.FloorService;
import com.wj.rpsm.admin.service.RoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;

/**
 * @author WeiJin
 * @version 1.0
 */
@RestController
@Api(tags = "房间相关接口")
public class RoomController {

    @Autowired
    RoomService roomService;

    @Autowired
    private FloorService floorService;

    @GetMapping("/page/room")
    @ApiOperation(value = "查询房间分页信息",
            response = Room.class,
            responseContainer = "list",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current",value = "当前页数",
                    defaultValue = "1",dataType = "Integer",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "页面行数",dataType = "Integer",
                    paramType = "query",defaultValue = "10"),
            @ApiImplicitParam(name = "number",value = "房间编号",dataType = "String",paramType = "query")
    })
    public ResponsePojo<PageResult<Room>> pageOfRoom(
            @RequestParam(defaultValue = "1")Integer current,
            String number,
            @RequestParam(defaultValue = "10")Integer size){
        PageResult<Room> rooms = roomService.pageOfRoom(current,size,number);
        return ResponsePojo.success(rooms);
    }
}
